package com.crazy.crazybusinessservice.mapper;

import com.crazy.crazymodel.model.entity.NetWorth;
import org.apache.ibatis.annotations.*;

import javax.xml.crypto.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;

@Mapper
public interface NetworthMapper {

    @Select("select * from net_worth")
    List<NetWorth> selectAllNetworth(); // 输出所有产品的净值数据信息

    @Select("select netValue from net_worth where id = ${id}")
    BigDecimal selectNetworthByproductId(long id); // 根据产品Id查询净值

    @Select("select productID from  net_worth")
    List<Integer> selectProductId(); // 查询所有产品Id


    @Update("update net_worth set netValue = ${networth} where id = ${id}")
    void updateNetworthById(@Param("id") int id, @Param("networth") BigDecimal networth); // 根据Id更新产品净值

    @Update("UPDATE net_worth SET netValue = netValue * (0.9 + RAND() * (1.1 - 0.9))")
    void updateDailyNetworth();


    @Insert("insert into audit_record(initializationStatus,auditDate) value (${initializationStatus},'${updateTime}')")
    void insertDayInitialization(@Param("initializationStatus") int initializationStatus, @Param("updateTime") String updateTime);

}
